<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>register</title>
    <script src="js/jquery-3.2.1.min.js"></script>
</head>
<body>
<table>
    <tr>
        <td>用户名:</td>
        <td><input type="text" class="username"><br></td>
        <td class="usertishi"></td>
    </tr>
    <tr>
        <td>密码:</td>
        <td><input type="text" class="password"><br></td>
        <td class="tishi"></td>
    </tr>
    <tr>
        <td>重复密码:</td>
        <td><input type="text" class="repwd"><br></td>
        <td class="tishi"></td>
    </tr>
    <tr>
        <td>email:</td>
        <td><input type="text" class="email"><br></td>
    </tr>
    <tr>
        <td>电话号码:</td>
        <td><input type="text" class="phone"></td>
    </tr>
    <tr>
        <td>个人简介:</td>
        <td><input type="text" class="summary"><br></td>
    </tr>
    <tr>
        <td>性别:</td>
        <td><input type="radio" name="gender" class="gender" value="0">男
        <input type="radio"  name="gender" class="gender" value="1">女<br></td>
    </tr>
    <tr>
        <td>年龄:</td><td>
        <input type="text" class="age"></td>
    </tr>
    <tr>
        <td><input type="button" class="register" value="注册"></td>
        <td><input type="reset"></td>
    </tr>
</table>
<script>
$(".register").click(function () {
    var username = $(".username").val();
    var password = $(".password").val();
    var repwd = $(".repwd").val();
    var email = $(".email").val();
    var phone = $(".phone").val();
    var summary = $(".summary").val();
    var gender = $("input[name='gender']:checked").val();
    var age = $(".age").val();
    console.log(username);
    console.log(password);
    console.log(repwd);
    console.log(email);
    console.log(phone);
    console.log(summary);
    console.log(gender);
    console.log(age);
    $.ajax({
        url:"http://47.104.87.243:8081/reg",
        type:"post",
        data:{
            username:username,
            password:password,
            repwd:repwd,
            email:email,
            phone:phone,
            summary:summary,
            gender:gender,
            age:age
        },
        success:function (re) {
            console.log(2222);
            if (re.code === 1003) {
                console.log(111);
                $(".usertishi").html(re.msg);
            }else if (re.code === 1005) {
                $(".tishi").html(re.msg);
            }else if (re.code === 1000) {
                alert("注册成功");
                location.href = "login.html";
            }
        }
    })

})
</script>
</body>
</html>